package com.villaday.idf.activity;

import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.villaday.idf.R;
import com.villaday.idf.base.BaseActivity;
import com.villaday.idf.custom.CircleTextView;
import com.villaday.idf.model3.AddressPostEntity;
import com.villaday.idf.util.Constant;
import com.villaday.idf.util.LogUtil;
import com.villaday.idf.util.OkHttpUtil;
import com.villaday.idf.util.ToolBarUtil;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;

public class AddressAddActivity extends BaseActivity {


    @BindView(R.id.toolbar_iconBack)
    ImageButton toolbarIconBack;
    @BindView(R.id.toolbar_iconTitle)
    TextView toolbarIconTitle;
    @BindView(R.id.toolbar_iconNext)
    ImageButton toolbarIconNext;
    @BindView(R.id.toolbar_iconCartDot)
    CircleTextView toolbarIconCartDot;
    @BindView(R.id.toolbar_iconLine)
    View toolbarIconLine;
    @BindView(R.id.toolbar_icon)
    Toolbar toolbarIcon;
    @BindView(R.id.tv_aa_name)
    TextView tvAaName;
    @BindView(R.id.et_ca_name)
    EditText etCaName;
    @BindView(R.id.vw_ca_name)
    View vwCaName;
    @BindView(R.id.tv_ca_phone)
    TextView tvCaPhone;
    @BindView(R.id.et_ca_phones)
    EditText etCaPhones;
    @BindView(R.id.vw_ca_phone)
    View vwCaPhone;
    @BindView(R.id.tv_ca_address)
    TextView tvCaAddress;
    @BindView(R.id.et_ca_address)
    EditText etCaAddress;
    @BindView(R.id.vw_ca_address)
    View vwCaAddress;
    @BindView(R.id.tv_aa_address_details)
    TextView tvAaAddressDetails;
    @BindView(R.id.et_aa_address_details)
    EditText etAaAddressDetails;
    @BindView(R.id.vw_aa_address_details)
    View vwAaAddressDetails;
    @BindView(R.id.rl_ca_name)
    RelativeLayout rlCaName;
    @BindView(R.id.tv_ca_email_left)
    TextView tvCaEmailLeft;
    @BindView(R.id.rl_aa_address)
    LinearLayout rlAaAddress;

    private String id;

    @Override
    protected int getViewResId() {
        return R.layout.activity_address_add;
    }

    @Override
    protected void init() {
        super.init();
        ToolBarUtil.initToolBar(toolbarIcon, "编辑地址", new View.OnClickListener() {

            @Override
            public void onClick(View v) {

            }
        }, R.drawable.public_delete, new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                AddressPostEntity addressPostEntity = new AddressPostEntity();
                addressPostEntity.setAction("2");
                addressPostEntity.setId(id);
                addressPostEntity.setCode("440307");
                addressPostEntity.setAddress("");
                addressPostEntity.setLinkman("");
                addressPostEntity.setMobile("");
                addressPostEntity.setPreferred(false);
                Map<String, Object> map = new HashMap<>();
                OkHttpUtil.postJson(AddressAddActivity.this, Constant.URL.getAddresses, addressPostEntity, map, new OkHttpUtil.OnDataListener() {
                    @Override
                    public void onResponse(String url, String json) {
                        LogUtil.jLog().e(json);
                        finish();
                    }

                    @Override
                    public void onFailure(String url, String error) {

                    }
                });
            }
        });
    }
}
